package com.ivideo.backend.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @Project: ivideo-parent
 * @Name: Knife4jConfig
 * @Author: Jack_Li
 * @Date: 2024/5/20 14:33
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {

    /**
     * 通过knife4j生成接口文档
     * @return
     */
    @Bean
    public Docket managementApi() {
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("爱观影项目接口文档")
                .version("1.0")
                .description("爱观影项目接口文档")
                .build();
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .groupName("管理端接口")
                .apiInfo(apiInfo)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ivideo.backend.controller.admin"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    @Bean
    public Docket clientApi() {
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("爱观影项目接口文档")
                .version("1.0")
                .description("爱观影项目接口文档")
                .build();
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .groupName("用户端接口")
                .apiInfo(apiInfo)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ivideo.backend.controller.client"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

}
